<?php
  require(dirname(__FILE__).'/global.php');
  require(ROOT.'/include/file.class.php');
  require(ROOT.'/admin/isLogin.php');
  
  $action = $_POST['action'];
  if(!isset($action)){
      $dir = ROOT.'/attachment';               
      require(ROOT.'/include/date.class.php');
      require(ROOT.'/include/data.class.php');
      $array = FileUtil::getFileList($dir);
      $smarty->assign('array',$array);
      $smarty->display('attach.html');
  }
  else{
      if($action == 'delete' ){
          $filename = $_POST['file'];
          $dir = substr($filename,0,8);
          $file = ROOT.'/attachment/'.$dir.'/'.$filename;
          
          FileUtil::delete($file);
          echo json_encode("success");
      }
  }
?>